function EventEmiter(){
    this.event = {};
}
EventEmiter.prototype.on = function(eventName,callback){
    if(!this.event[eventName]){
        this.event[eventName] = [callback];
    }else{
        this.event[eventName].push(callback);
    }
}
EventEmiter.prototype.emit = function(eventName,...args){
    if(!this.event[eventName]){
        throw new Error("没有注册此事件")
    }else{
        this.event[eventName].forEach(callback=>{
            callback(...args);
        })
    }
}
//订阅，执行后就移除这个事件
EventEmiter.prototype.once = function(eventName,callback){
    let fn = ()=>{
        callback();
        this.remove(eventName,fn);
    }
    this.on(eventName,fn);
}
EventEmiter.prototype.remove = function(eventName,callback){
    if(!this.event[eventName]){
        throw new Error("没有注册此事件")
    }else{
        this.event[eventName].forEach.filter(item=>{
            return item !==callback;
        })
    }
}

let e = new EventEmiter();
function clickhandler(){
    console.log("clickhandler");
}
function dbclickhandler(...args){
    console.log("dbclickhandler"+args)
}
e.on('click',clickhandler);
e.emit('click')
e.on('dbclick',dbclickhandler);
e.emit('dbclick',1,2,3,4,5)